package com.shareach.http.shop.parameter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import org.apache.commons.lang.StringUtils;

import com.shareach.web.basic.IAskParameter;

public class BizTuanShopParameter implements IAskParameter {
	public Long shopId;
	public String brandName;
	public String name;
	public String orgName;
	public String addr;
	public List<String> tels;
	public Double lat;
	public Double lng;
	public String fromId;
	
	private String trim(String value){
		if(!StringUtils.isBlank(value)){
			return value.trim();
		}else{
			return value;
		}
	}
	
	@SuppressWarnings("unchecked")
	@Override
	public void parseFromMap(HashMap<String, Object> map) {
		if(map.containsKey("shopId"))this.shopId = (Long)map.get("shopId");
		if(map.containsKey("brandName"))this.brandName = trim((String)map.get("brandName"));
		if(map.containsKey("name"))this.name = trim((String)map.get("name"));
		if(map.containsKey("orgName"))this.orgName = trim((String)map.get("orgName"));
		if(map.containsKey("addr"))this.addr = trim((String)map.get("addr"));
		if(map.containsKey("tels")&&map.get("tels")!=null){
			this.tels = (ArrayList<String>)map.get("tels");
		}
		if(map.containsKey("lat") && map.containsKey("lng")) {
			if(map.get("lat")!=null && map.get("lng")!=null && !map.get("lat").equals(0) && !map.get("lng").equals(0)){
				this.lng = (Double)map.get("lng");
				this.lat = (Double)map.get("lat");
			}
		}
		if(map.containsKey("fromId"))this.fromId = trim((String)map.get("fromId"));
	}
}
